package com.bawei.patient.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bawei.patient.vo.DoctorPatientMidVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bawei.patient.entity.DoctorPatientMidEntity;
import com.bawei.patient.service.DoctorPatientMidService;
import com.bawei.common.utils.PageUtils;
import com.bawei.common.utils.R;



/**
 * 医生患者中间表
 *
 * @author patient
 * @email sunlightcs@gmail.com
 * @date 2021-12-09 19:52:26
 */
@RestController
@RequestMapping("patient/doctorpatientmid")
public class DoctorPatientMidController {
    @Autowired
    private DoctorPatientMidService doctorPatientMidService;


    //患者诊断记录详细信息
    @GetMapping("/findByPatientId/{id}")
    public R findByPatientId(@PathVariable("id") Integer id){

        return doctorPatientMidService.findByPatientId(id);
    }

    /**
     * 列表
     */

    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        IPage<DoctorPatientMidEntity> page = doctorPatientMidService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @PostMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		DoctorPatientMidEntity doctorPatientMid = doctorPatientMidService.getById(id);


        return R.ok().put("doctorPatientMid", doctorPatientMid);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody DoctorPatientMidEntity doctorPatientMid){
		doctorPatientMidService.save(doctorPatientMid);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody DoctorPatientMidEntity doctorPatientMid){
		doctorPatientMidService.updateById(doctorPatientMid);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		doctorPatientMidService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
